import { _decorator, Camera, Component, director, Node} from 'cc';
import { CardGenerator } from './CardGenerate';
import { GLOBALPOP } from './GlobalPop';
const { ccclass, property } = _decorator;

@ccclass('GameManager')
export class GameManager extends Component {
    private static _instance: GameManager = null;

    @property({type: Node, tooltip: "卡牌容器"})
    private CardContainer: Node | null = null;
    @property({type: Camera, tooltip: "摄像机"})
    private Camera: Camera | null = null;
    @property({type: Node, tooltip: "失败面板"})
    private FailedPanel: Node | null = null;
    
    start() {
        GLOBALPOP.setFailedPanel(this.FailedPanel);
        GLOBALPOP.setCamera(this.Camera);
        GLOBALPOP.setCardContainer(this.CardContainer);
        CardGenerator.setCardContainer(this.CardContainer);
        CardGenerator.setCurrentCamera(this.Camera);
        CardGenerator.generateLevel();
    }

    update(deltaTime: number) {
        
    }
    
    public onClickRestart() {
        CardGenerator.restart();
    }
    onClickNotPlay() {
        director.loadScene("MenuScene");
    }

}